

//
//  DidiMainLeftView.m
//  didihaha
//
//  Created by 赵忠鹏 on 2017/8/3.
//  Copyright © 2017年 zhaozhongpeng. All rights reserved.
//

#import "DidiMainLeftView.h"
#import "Masonry.h"
#import "DidMainRectView.h"
#import "DiDiShareInstance.h"

@interface DidiMainLeftView ()

#pragma mark - 圈

@property (nonatomic, strong)DidMainRectView *oneRectView;

@property (nonatomic, strong)DidMainRectView *twoRectView;

@property (nonatomic, strong)DidMainRectView *threeRectView;

@end

@implementation DidiMainLeftView


- (instancetype)init{
    if (self = [super init]) {
        self.backgroundColor = [UIColor whiteColor];
        [self createUI];
    }
    return self;
}

- (void)createUI{
    [self addSubview:self.topHeadImage];
    [self addSubview:self.phoneNumLabel];
    [self addSubview:self.VIPLable];
    [self addSubview:self.journeyBtn];
    [self addSubview:self.walletBtn];
    [self addSubview:self.serviceBtn];
    [self addSubview:self.setbtn];
    [self addSubview:self.triangleBtn];
    [self addSubview:self.oneRectView];
    [self addSubview:self.twoRectView];
    [self addSubview:self.threeRectView];
    
    [self.topHeadImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.width.height.mas_equalTo(60);
        make.centerY.equalTo(self.mas_top).offset(80);
    }];
    
    [self.phoneNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.topHeadImage.mas_bottom).offset(8);
    }];
    
    [self.VIPLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.phoneNumLabel.mas_bottom).offset(12);
    }];
    
    [self.journeyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(20);
        make.top.equalTo(self.VIPLable.mas_bottom).offset(40);
    }];
    
    [self.walletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.journeyBtn.mas_left);
        make.top.equalTo(self.journeyBtn.mas_bottom).offset(30);
    }];
    
    [self.serviceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.journeyBtn.mas_left);
        make.top.equalTo(self.walletBtn.mas_bottom).offset(30);
    }];
    
    [self.setbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.journeyBtn.mas_left);
        make.top.equalTo(self.serviceBtn.mas_bottom).offset(30);
    }];
    
    [self.triangleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self.mas_bottom).offset(-100);
        make.width.height.mas_equalTo(15);
    }];
    
    [self.oneRectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(15);
        make.top.equalTo(self.triangleBtn.mas_bottom).offset(15);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
        make.width.mas_equalTo(45);
    }];
    
    [self.twoRectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.bottom.top.equalTo(self.oneRectView);
         make.left.equalTo(self.oneRectView.mas_right).offset(10);
    }];
    
    
    [self.threeRectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.bottom.top.equalTo(self.oneRectView);
        make.left.equalTo(self.twoRectView.mas_right).offset(10);
    }];
    
}


#pragma mark - 懒加载
- (UIImageView *)topHeadImage{
    if (_topHeadImage  == nil) {
        // @"passenger_head"
        _topHeadImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passenger_head"]];
        _topHeadImage.layer.cornerRadius = 30;
        _topHeadImage.clipsToBounds = YES;
        _topHeadImage.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _topHeadImage.layer.borderWidth = 0.2;
    }
    return _topHeadImage;
}


- (UILabel *)phoneNumLabel{
    
    if (_phoneNumLabel == nil) {
        _phoneNumLabel = [[UILabel alloc] init];
        _phoneNumLabel.font = [UIFont systemFontOfSize:15];
        _phoneNumLabel.text = @"176****8755";
        _phoneNumLabel.textAlignment = NSTextAlignmentCenter;
        if ([[[DiDiShareInstance shareInstance].dataDic objectForKey:@"userPhoneNum"] length] > 0) {
            _phoneNumLabel.text = [[DiDiShareInstance shareInstance].dataDic objectForKey:@"userPhoneNum"];
        }
    }
    return _phoneNumLabel;
    
}

- (UILabel *)VIPLable{
    if (_VIPLable == nil) {
        _VIPLable  =[[UILabel alloc] init];
        _VIPLable.font = [UIFont systemFontOfSize:10];
        _VIPLable.textAlignment = NSTextAlignmentCenter;
        _VIPLable.textColor = [UIColor colorWithRed:133/255.0 green:133/255.0 blue:133/255.0 alpha:1];
        NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"  普通会员"]; // 普通会员
        NSTextAttachment *attch = [[NSTextAttachment alloc] init];
        //定义图片内容及位置和大小
        attch.image = [UIImage imageNamed:@"common_image_replace"];//
        attch.bounds = CGRectMake(0, -2, 12, 12);
        //创建带有图片的富文本
        NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
        
        [attString insertAttributedString:string atIndex:0];
        _VIPLable.attributedText = attString;
        
    }
    return _VIPLable;
}

#pragma mark - 按钮
- (UIButton *)journeyBtn{
    if (_journeyBtn == nil) {
        _journeyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_journeyBtn setTitle:@"    行程" forState:UIControlStateNormal];
        _journeyBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_journeyBtn setTitleColor:[UIColor colorWithRed:38/255.0 green:38/255.0 blue:38/255.0 alpha:1] forState:UIControlStateNormal];
        [_journeyBtn setImage:[UIImage imageNamed:@"personal_icon_trip"] forState:UIControlStateNormal];
        
    }
    return _journeyBtn;
}

- (UIButton *)walletBtn{
    if (_walletBtn == nil) {
        _walletBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_walletBtn setTitle:@"    钱包" forState:UIControlStateNormal];
        _walletBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_walletBtn setTitleColor:[UIColor colorWithRed:38/255.0 green:38/255.0 blue:38/255.0 alpha:1] forState:UIControlStateNormal];
        [_walletBtn setImage:[UIImage imageNamed:@"personal_icon_wallet"] forState:UIControlStateNormal];
    }
    return _walletBtn;
}


- (UIButton *)serviceBtn{
    if (_serviceBtn == nil) {
        _serviceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_serviceBtn setTitle:@"    客服" forState:UIControlStateNormal];
        _serviceBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_serviceBtn setTitleColor:[UIColor colorWithRed:38/255.0 green:38/255.0 blue:38/255.0 alpha:1] forState:UIControlStateNormal];
        [_serviceBtn setImage:[UIImage imageNamed:@"personal_icon_help"] forState:UIControlStateNormal];
    }
    return _serviceBtn;
}

- (UIButton *)setbtn{
    if (_setbtn == nil) {
        _setbtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_setbtn setTitle:@"    设置" forState:UIControlStateNormal];
        _setbtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [_setbtn setTitleColor:[UIColor colorWithRed:38/255.0 green:38/255.0 blue:38/255.0 alpha:1] forState:UIControlStateNormal];
        [_setbtn setImage:[UIImage imageNamed:@"personal_icon_setting"] forState:UIControlStateNormal];
    }
    return _setbtn;
}

- (UIButton *)triangleBtn{
    if (_triangleBtn == nil) {
        _triangleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_triangleBtn setImage:[UIImage imageNamed:@"common_icon_up"] forState:UIControlStateNormal];
    }
    return _triangleBtn;
}


#pragma 圈

- (DidMainRectView *)oneRectView{
    if (_oneRectView == nil) {
        _oneRectView = [[DidMainRectView alloc] init];
        _oneRectView.RectImageView.image = [UIImage imageNamed:@"CIP_icon_fastpass_gray"];
        _oneRectView.RectLabel.text = @"积分商城";
    }
    return _oneRectView;
}

- (DidMainRectView *)twoRectView{
    if (_twoRectView == nil) {
        _twoRectView = [[DidMainRectView alloc] init];
        _twoRectView.RectImageView.image = [UIImage imageNamed:@"CIP_icon_guide_gray"];
        _twoRectView.RectLabel.text = @"推荐有奖";
    }
    return _twoRectView;
}

- (DidMainRectView *)threeRectView{
    if (_threeRectView == nil) {
        _threeRectView = [[DidMainRectView alloc] init];
        _threeRectView.RectImageView.image = [UIImage imageNamed:@"CIP_icon_fastpass_gray"];
        _threeRectView.RectLabel.text = @"车主招募";
    }
    return _threeRectView;
}

@end
